<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserHasDocumentTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('qh_user_has_document', function (Blueprint $table) {
            $table->id();
            $table->integer('userId', false, true)->comment('用户ID');
            $table->integer('documentId', false, true)->comment('文档ID');
            $table->tinyInteger('type')->default(1)->comment('获得类型1=购买,2=激活,3=发放');
            $table->integer('orderId', false, true)->nullable()->comment('订单ID');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE qh_user_has_document comment '用户购买的文档'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('qh_user_has_document');
    }
}
